function findSmallestInteger(nums, value) {
  const count = new Array(value).fill(0);
  for (const num of nums) {
    // 计算num模value的非负余数
    let rem = num % value;
    if (rem < 0) {
      rem += value;
    }
    count[rem]++;
  }
  let k = 0;
  while (true) {
    const r = k % value;
    const q = Math.floor(k / value);
    if (count[r] <= q) {
      return k;
    }
    k++;
  }
}
